package cn.gov.service.impl;

import cn.gov.dao.IPersonalAccountDAO;
import cn.gov.service.IServicePersonalAccountService;
import cn.gov.vo.PersonalAccount;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ServicePersonalAccountServiceImpl implements IServicePersonalAccountService {

    @Autowired
    private IPersonalAccountDAO servicePersonalAccountDAO;

    @Override
    public List<PersonalAccount> all() {
        return servicePersonalAccountDAO.findAll();
    }

    @Override
    public PersonalAccount get(String mobile) {
        return servicePersonalAccountDAO.queryMobile(mobile);
    }

    @Override
    public Map<String, Object> login(String mobile) {
        Map<String, Object> map = new HashMap<>();
        PersonalAccount personalAccount = this.servicePersonalAccountDAO.queryMobile(mobile);
        if (personalAccount == null) {    // 用户不存在
            return map;
        }
        map.put("name", personalAccount.getName());
        return map;
    }
}
